#pragma once
#include"RBTree.h"

namespace bit
{
	template<class K,class V>
	class my_map
	{
		struct MapOfValue
		{
			const K& operator()(const pair<K,V> kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename RBTree<K, const pair<K,V>, MapOfValue>::iterator iterator;
		typedef typename RBTree<K, const pair<K,V>, MapOfValue>::const_iterator const_iterator;
		pair<iterator,bool> insert(const K& key)
		{
			return _t.insert(key);
		}
		iterator begin()
		{
			return _t.Begin();
		}
		const_iterator begin() const
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End()
		}
		const_iterator end() const
		{
			return _t.End()
		}

		V operator[](const K& key)
		{
			pair(iterator, bool) ret = _t.insert(key);
			return ret->second;
		}

	private:
		RBTree<K, const K, MapOfValue> _t;
	};
}